package com.whisper.application.service.service.impl;

import com.whisper.application.service.domain.VrArticle;
import com.whisper.application.service.mapper.VrArticleMapper;
import com.whisper.application.service.service.IVrArticleService;
import com.whisper.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.whisper.common.security.util.SecurityUtils.getUsername;

/**
 * 文章Service业务层处理
 * 
 * @author whisper
 * @date 2024-01-07
 */
@Service
public class VrArticleServiceImpl implements IVrArticleService 
{
    @Autowired
    private VrArticleMapper vrArticleMapper;

    /**
     * 查询文章
     * 
     * @param id 文章主键
     * @return 文章
     */
    @Override
    public VrArticle selectVrArticleById(Long id)
    {
        return vrArticleMapper.selectVrArticleById(id);
    }

    /**
     * 查询文章列表
     * 
     * @param vrArticle 文章
     * @return 文章
     */
    @Override
    public List<VrArticle> selectVrArticleList(VrArticle vrArticle)
    {
        return vrArticleMapper.selectVrArticleList(vrArticle);
    }

    /**
     * 新增文章
     * 
     * @param vrArticle 文章
     * @return 结果
     */
    @Override
    public int insertVrArticle(VrArticle vrArticle)
    {
        vrArticle.setCreateTime(DateUtils.getNowDate());
        vrArticle.setCreateBy(getUsername());
        return vrArticleMapper.insertVrArticle(vrArticle);
    }

    /**
     * 修改文章
     * 
     * @param vrArticle 文章
     * @return 结果
     */
    @Override
    public int updateVrArticle(VrArticle vrArticle)
    {
        vrArticle.setUpdateTime(DateUtils.getNowDate());
        vrArticle.setUpdateBy(getUsername());
        return vrArticleMapper.updateVrArticle(vrArticle);
    }

    /**
     * 批量删除文章
     * 
     * @param ids 需要删除的文章主键
     * @return 结果
     */
    @Override
    public int deleteVrArticleByIds(Long[] ids)
    {
        return vrArticleMapper.deleteVrArticleByIds(ids);
    }

    /**
     * 删除文章信息
     * 
     * @param id 文章主键
     * @return 结果
     */
    @Override
    public int deleteVrArticleById(Long id)
    {
        return vrArticleMapper.deleteVrArticleById(id);
    }

    @Override
    public List<VrArticle> selectVrArticleOrderByCreateTimeLimit(Integer limit) {
        return vrArticleMapper.selectVrArticleListByCreateTimeLimit();
    }
}
